package com.dj.dormitory.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dj.dormitory.entity.Grade;
import com.dj.dormitory.entity.User;
import com.dj.dormitory.mapper.GradeMapper;
import com.dj.dormitory.service.GradeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author DJ同学
 * @since 2021-01-24
 */
@Service
public class GradeServiceImpl extends ServiceImpl<GradeMapper, Grade> implements GradeService {

    @Override
    public Page<Grade> getPartList(Map map) {
        QueryWrapper wrapper = new QueryWrapper();
        if(map.containsKey("name")&&!StringUtils.isEmpty((String)map.get("name"))){
            wrapper.like("name",map.get("name"));
        }
        Integer cur = (Integer) map.get("page");
        Integer limit = (Integer) map.get("limit");
        Page<Grade> page = new Page<>(cur,limit);
        this.baseMapper.selectPage(page,wrapper);
        return page;
    }
}
